<html>
<head><meta charset="utf-8"><title>REPL: RustcSerialize vs manual · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html">REPL: RustcSerialize vs manual</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="182189748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182189748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182189748">(Nov 29 2019 at 16:28)</a>:</h4>
<p>both the <code>user_fn</code> frame and the <code>Memory</code> need to be serialized and restored. Currently <span class="user-mention" data-user-id="124069">@Alexander Regueiro</span> has implemented a manual scheme, and iirc wanted to check again why <code>RustcSerialize</code> and <code>RustcDeserialize</code> aren't used instead</p>



<a name="182190122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182190122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182190122">(Nov 29 2019 at 16:34)</a>:</h4>
<p>So, I believe I experimented with this some time ago (you may have suggested this formerly), and basically the issue was that a) it pulled in memory from the start fn and main's params</p>



<a name="182190135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182190135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182190135">(Nov 29 2019 at 16:35)</a>:</h4>
<p>b) the <code>dead_alloc_map</code> isn't something that we really want to serialise, I think</p>



<a name="182190229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182190229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182190229">(Nov 29 2019 at 16:36)</a>:</h4>
<p>you need the <code>dead_alloc_map</code> for a few operations. If it's not there you may run into trouble when doing things to dangling pointers</p>



<a name="182190239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182190239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182190239">(Nov 29 2019 at 16:36)</a>:</h4>
<p>and trust me, users will do evil things with a REPL :D</p>



<a name="182190402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182190402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182190402">(Nov 29 2019 at 16:39)</a>:</h4>
<p>about the wasted memory. Essentially the way you serialize is to serialize the frame of the closure, write down all alloc ids, serialize the corresponding <code>Alloations</code> for the alloc ids, again writing down all new alloc ids encountered?</p>



<a name="182193210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182193210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182193210">(Nov 29 2019 at 17:28)</a>:</h4>
<p>hmm I see</p>



<a name="182193239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182193239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182193239">(Nov 29 2019 at 17:28)</a>:</h4>
<p>I will look into this for sure</p>



<a name="182193242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182193242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182193242">(Nov 29 2019 at 17:28)</a>:</h4>
<p>I don't think it affects the first couple of PRs</p>



<a name="182193262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182193262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182193262">(Nov 29 2019 at 17:29)</a>:</h4>
<p>and a <code>RustcSeriaze/Deserialize</code> implementation for <code>Memory</code> should not be too hard. I'm sure I implemented it before and reverted it.</p>



<a name="182193267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182193267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182193267">(Nov 29 2019 at 17:29)</a>:</h4>
<p>will do a bit more experimentation before opening the MIR PR, of course</p>



<a name="182196200"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182196200" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182196200">(Nov 29 2019 at 18:20)</a>:</h4>
<p>I think you're right in that a manual deserialization works better, because it can skip everything that is not needed</p>



<a name="182196212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182196212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182196212">(Nov 29 2019 at 18:20)</a>:</h4>
<p>But yea, you'll have to also preserve the dead alloc map entries that are reachable</p>



<a name="182196479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182196479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182196479">(Nov 29 2019 at 18:26)</a>:</h4>
<p>okay, so I think we're in agreement there. I'll just make sure the dead alloc map gets serialised now! (I guess my simple test cases didn't catch problems with that, but indeed, someone would find a way to break it heh...)</p>



<a name="182197729"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182197729" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182197729">(Nov 29 2019 at 18:53)</a>:</h4>
<p>Should the stacked borrow state be serialized too?</p>



<a name="182201761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182201761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182201761">(Nov 29 2019 at 20:14)</a>:</h4>
<p>what exactly do you mean <span class="user-mention" data-user-id="133247">@bjorn3</span> ?</p>



<a name="182202434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182202434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182202434">(Nov 29 2019 at 20:28)</a>:</h4>
<p>Stacked borrows is kind of a runtime version of the borrowchecker. To make it work correctly, it's state should be serialized too.</p>



<a name="182202663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182202663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182202663">(Nov 29 2019 at 20:32)</a>:</h4>
<p>oh sorry, I parsed your sentence invalidly.</p>



<a name="182202672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182202672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182202672">(Nov 29 2019 at 20:32)</a>:</h4>
<p>it currently is serialised for the miri backend, in fact.</p>



<a name="182202690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182202690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182202690">(Nov 29 2019 at 20:32)</a>:</h4>
<p>it's "just" a dynamic correctness check though, as far as I'm aware? so it's not necessary for the Codegen backend.</p>



<a name="182202867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182202867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182202867">(Nov 29 2019 at 20:36)</a>:</h4>
<p>indeed, cg_llvm doesn't implement it either. it requires a lot of dynamic instrumentation (every call and every borrow/deref) to implement it.</p>



<a name="182202873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182202873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182202873">(Nov 29 2019 at 20:36)</a>:</h4>
<p>yep, I think this is fine. :-)</p>



<a name="182202886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182202886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182202886">(Nov 29 2019 at 20:36)</a>:</h4>
<p>easy enough to say "if you want this sort of dynamic correctness checking, just use the miri backend".</p>



<a name="182202911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182202911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182202911">(Nov 29 2019 at 20:37)</a>:</h4>
<p>yeah, it doesn't make much sense without the other UB checks anyway</p>



<a name="182202945"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/REPL%3A%20RustcSerialize%20vs%20manual/near/182202945" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alexander Regueiro <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/REPL.3A.20RustcSerialize.20vs.20manual.html#182202945">(Nov 29 2019 at 20:38)</a>:</h4>
<p>true</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>